package com.chinaunicom.order.domain.model.entity;

import com.chinaunicom.common.exception.BusinessException;
import com.chinaunicom.order.domain.model.valobj.OrderStatus;
import lombok.Data;

import java.util.Objects;

/**
 * @author guomenghuai
 * @date 2024/1/15
 * @Description
 */
@Data
public class CancelOrderEntity {

    private Long orderId;

    private Long userId;

    private Integer orderStatus;

    public void checkCancelOrderRequestParam() {
        //  订单状态
        Integer orderStatus = this.orderStatus;
        if (Objects.isNull(orderStatus)) {
            throw new BusinessException("订单状态不能为空");
        }

        if (Objects.equals(OrderStatus.CANCELED.getCode(), orderStatus)) {
            throw new BusinessException("订单已取消");
        }

        if (Objects.isNull(this.orderId)) {
            throw new BusinessException("订单id为空");
        }
    }

}
